package ch9;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Insert2 {
    public static void main(String[] args) {
        int p[]={98,86,66,62,60,0};
        Scanner in=new Scanner(System.in);
        System.out.println("input:");
        int k=in.nextInt();//保证p依然是降序的
        int index=0;
        while (index<p.length-1){
            if(p[index]<k)
                break;
            index++;
        }
        //index就是合适的位置
        System.out.println(index);
        //移动，倒着来
        for(int i=p.length-2;i>=index;i--){
            p[i+1]=p[i];
        }
        p[index]=k;
        for(int i=0;i<p.length;i++)
            System.out.print(p[i]+" ");
    }
}
